<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
require_once APPLICATION_PATH.'/misc/additional.php';
class Application_Controllers_Complain_ActionResponseComplain
{
    public $errorMessage="";

    public function preResponse($form){
        return true;
    }
    public function onResponse($form){
        $additional = new Additional();
        $complain = new Application_Model_DbTable_Complain();
        $buyer = new Application_Model_DbTable_Buyers();
        $rowComplain = $complain->fetchRow("id=".$form->getValue('id'));
        $rowB = $buyer->fetchRow("buyer_id=".$rowComplain['buyer_id']);
        
        $timeStamp = mktime(date('H'),date('i'), date('s')
                            ,date('m'),date('d'),date('y'));
        $dob_disp1=strftime('%Y-%m-%d %H:%M:%S',$timeStamp);
        $array=array('response_msg'=>$form->getValue('response_msg'),
                    'admin_id'=>$form->getValue('admin_id'),
                    'response'=>$dob_disp1,
                    'status'=>1);
         $subject="Re:".$rowComplain['title'];
         $body = 'Dear Mr/Ms/Mrs'.$rowB['name']." \n ".$form->getValue('response_msg');
        $additional->sendEmail($body, array($rowB["email"]=>$rowB["name"])
                 ,$subject);
//echo     "admin id :".$form->getValue('admin_id');
$complain->update($array,"id=".(int)$form->getValue('id'));

    }
}
?>
